//
//  DetailTableViewCell.m
//  BeautyClother
//
//  Created by dllo on 15/8/27.
//  Copyright (c) 2015年 宋爽. All rights reserved.
//

#import "DetailTableViewCell.h"

@interface DetailTableViewCell ()

@property (nonatomic, assign) CGFloat offWidth;
@property (nonatomic, assign) CGFloat offHeight;

@end

@implementation DetailTableViewCell



- (void)dealloc
{
    [_icon release];
    [_image release];
    [_title release];
    [_price release];
    [_priceOrig release];
    [_discount release];
    [_take release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.image = [[UIImageView alloc]init];
        [self.contentView addSubview:self.image];
        [_image release];
        
        self.icon = [[UIImageView alloc]init];
        [self.image addSubview:_icon];
        [self.icon release];
        
        self.title = [[UILabel alloc]init];
        [self.contentView addSubview:self.title];
        [_title release];
        
        self.price = [[UILabel alloc]init];
        [self.contentView addSubview:self.price];
        [_price release];
        
        self.priceOrig = [[UILabel alloc]init];
        [self.contentView addSubview:self.priceOrig];
        [_priceOrig release];
        
        self.people = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.contentView addSubview:self.people];
        
        self.discount = [[UILabel alloc]init];
        [self.contentView addSubview:self.discount];
        [_discount release];
        self.take = [[UILabel alloc]init];
        [self.contentView addSubview:self.take];
        [_take release];
        
        self.offWidth = [[UIScreen mainScreen]bounds].size.width / 375;
        self.offHeight = [[UIScreen mainScreen]bounds].size.height / 667;
        
    }
    return self;
}


- (void)layoutSubviews
{
    [super layoutSubviews];
    self.image.frame = CGRectMake(5*_offWidth, 5 *_offHeight, 150*_offWidth, self.frame.size.height - 10*_offHeight);
    self.image.layer.cornerRadius = 5;
    self.image.layer.masksToBounds = YES;
    self.icon.frame = CGRectMake(0, 0, 50*_offWidth, 20*_offHeight);
    self.title.frame = CGRectMake(160*_offWidth, 5*_offHeight, self.frame.size.width - 170*_offWidth, 50*_offHeight);
    self.title.numberOfLines = 2;
    self.title.font = [UIFont systemFontOfSize:18];
    self.title.textColor = [UIColor darkGrayColor];
    
    self.price.frame = CGRectMake(160*_offWidth, 70*_offHeight, 50*_offWidth, 30*_offHeight);
    self.price.textColor = [UIColor colorWithRed:255/255 green:0 blue:255/255 alpha:0.8];
    self.price.font = [UIFont boldSystemFontOfSize:20];
    self.priceOrig.frame = CGRectMake(215*_offWidth, 80*_offHeight, 40*_offWidth, 10*_offHeight);
    self.priceOrig.textColor = [UIColor lightGrayColor];
    self.priceOrig.font = [UIFont systemFontOfSize:10];
    self.people.frame = CGRectMake(160*_offWidth, 105*_offHeight, 60*_offWidth, 10*_offHeight);
    self.people.titleLabel.font = [UIFont systemFontOfSize:10];
    [self.people setTitleColor:[UIColor colorWithRed:255/255 green:0 blue:255/255 alpha:0.5 ] forState:UIControlStateNormal];
    
    self.discount.frame = CGRectMake(160*_offWidth, 120*_offHeight, 50*_offWidth, 20*_offHeight);
    self.discount.backgroundColor = [UIColor lightGrayColor];
    self.discount.layer.cornerRadius = 5;
    self.discount.layer.masksToBounds = YES;
    self.discount.textAlignment = 1;
    self.discount.textColor = [UIColor whiteColor];
    
    
#pragma mark - 
#pragma mark -设置删除线
    NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:self.priceOrig.text];
    [attri addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlinePatternSolid | NSUnderlineStyleSingle) range:NSMakeRange(0, self.priceOrig.text.length)];
    [attri addAttribute:NSStrikethroughColorAttributeName value:[UIColor darkGrayColor] range:NSMakeRange(0, self.priceOrig.text.length)];
    [self.priceOrig setAttributedText:attri];
    
    
    self.take.frame = CGRectMake(275*_offWidth, 100*_offHeight, 120*_offWidth, 50*_offHeight);
    self.take.backgroundColor = [UIColor colorWithRed:255/255 green:0 blue:255/255 alpha:0.2];
    self.take.font = [UIFont boldSystemFontOfSize:19];
    self.take.textColor = [UIColor whiteColor];
    self.take.textAlignment = 1;
    self.take.layer.cornerRadius = 25;
    self.take.layer.masksToBounds = YES;
    

}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
